package servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

import entity.OyxVipLevelShow;

import oyxUtil.OyxVipPageUtil;
import service.OyxUser_levelMessageService;
import service.OyxVipUsermessageService;
import service.impl.OyxUser_levelMessageServiceImpl;
import service.impl.OyxVipUsermessageServiceImpl;


public class OyxVipLevelShowServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");		
		OyxVipUsermessageService vum = new OyxVipUsermessageServiceImpl();
		OyxUser_levelMessageService ulms = new OyxUser_levelMessageServiceImpl();
		String parameter = request.getParameter("vipLever01");
		request.setAttribute("vipLever01", parameter);
		int parseInt = Integer.parseInt(parameter);
		
		//获取 前端 传递过来的  pageNo
		String pageNo = request.getParameter("pageNo");
  		if(pageNo == null || "".equals(pageNo)){
  			pageNo ="1";
  		}
		

		//定义默认的 pageSize
		Integer pageSize = 1;
		//查询出 符合 条件的 总条数
		Integer rows = ulms.getRows(parseInt);
  		//合理化 pageNo
  		OyxVipPageUtil<OyxVipLevelShow> pageUtil = 
  				new OyxVipPageUtil<OyxVipLevelShow>(Integer.parseInt(pageNo),pageSize,rows);
		List<OyxVipLevelShow> vipUserLevelShow = vum.getVipUserLevelShow(parseInt,pageUtil.getPageNo(),pageUtil.getPageSize());
		pageUtil.setList(vipUserLevelShow);
		
		request.setAttribute("pageUtil", pageUtil);
        System.out.println(parameter);
		

	    request.getRequestDispatcher("Member_Member_List.jsp").forward(request, response);
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
